﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using WebBackgrounder;
using SmallShop.Services.Implements;

namespace BackEnd.Code
{
    //[assembly: WebActivator.PreApplicationStartMethod(typeof(AutoUpdate), "Start")]

    public static class AutoUpdate
    {
        private static readonly Timer _timer = new Timer(OnTimerElapsed);
        private static readonly JobHost _jobHost = new JobHost();

        public static void Start()
        {
            _timer.Change(TimeSpan.Zero, TimeSpan.FromHours(1));
        }

        private static void OnTimerElapsed(object sender)
        {
            _jobHost.DoWork(() => {
                UtilityService.UpdatePremiumUser();
            });
        }
    }
}